package com.jucai.pppeiyouclient.adapter;

import android.content.Context;

import com.jucai.pppeiyouclient.R;
import com.jucai.pppeiyouclient.base.CommonRecyclerViewAdapter;
import com.jucai.pppeiyouclient.bean.ActivityRecordBean;

import java.util.List;

/**
 * Created by Kuky on 2017-05-06.
 */

public class ActRecordAdapter extends CommonRecyclerViewAdapter<ActivityRecordBean> {
    public ActRecordAdapter(Context context, List<ActivityRecordBean> data) {
        super(context, data);
    }

    @Override
    public void bindHolder(CommonHolder holder, ActivityRecordBean activityRecordBean) {
        holder.setImage(R.id.act_record_img, activityRecordBean.getMember_avatar(), 60, 60);
        holder.setText(R.id.act_record_name, activityRecordBean.getMember_realname());
        if (activityRecordBean.getTactivity_type() == 1) {
            holder.setText(R.id.act_record_fee, "收取：" + Math.abs(activityRecordBean.getTactivity_price()));
        } else {
            holder.setText(R.id.act_record_fee, "支付：" + Math.abs(activityRecordBean.getTactivity_price()));
        }
        holder.setText(R.id.act_record_title, "标题：" + activityRecordBean.getTactivity_title());
        holder.setText(R.id.act_record_start_time, "开始时间：" + activityRecordBean.getTactivity_start_time());
        holder.setText(R.id.act_record_end_time, "结束时间：" + activityRecordBean.getTactivity_end_time());
        holder.setText(R.id.act_record_location, "集合地点：" + activityRecordBean.getTactivity_city());
        holder.setText(R.id.act_record_evaluate, "评语：" + activityRecordBean.getEvaluate());

        List<String> imageUrls = activityRecordBean.getImglist();
        if (imageUrls == null || imageUrls.size() == 0) {
            holder.setGone(R.id.act_record_ll);
        } else {
            if (imageUrls.size() == 1) {
                holder.setImage(R.id.act_record_pic_01, imageUrls.get(0), 45, 35);
                holder.setGone(R.id.act_record_pic_02);
                holder.setGone(R.id.act_record_pic_03);
                holder.setGone(R.id.act_record_pic_04);
            } else if (imageUrls.size() == 2) {
                holder.setImage(R.id.act_record_pic_01, imageUrls.get(0), 45, 35);
                holder.setImage(R.id.act_record_pic_02, imageUrls.get(1), 45, 35);
                holder.setGone(R.id.act_record_pic_03);
                holder.setGone(R.id.act_record_pic_04);
            } else if (imageUrls.size() == 3) {
                holder.setImage(R.id.act_record_pic_01, imageUrls.get(0), 45, 35);
                holder.setImage(R.id.act_record_pic_02, imageUrls.get(1), 45, 35);
                holder.setImage(R.id.act_record_pic_03, imageUrls.get(2), 45, 35);
                holder.setGone(R.id.act_record_pic_04);
            } else if (imageUrls.size() >= 4) {
                holder.setImage(R.id.act_record_pic_01, imageUrls.get(0), 45, 35);
                holder.setImage(R.id.act_record_pic_02, imageUrls.get(1), 45, 35);
                holder.setImage(R.id.act_record_pic_03, imageUrls.get(2), 45, 35);
                holder.setImage(R.id.act_record_pic_04, imageUrls.get(3), 45, 35);
            }
        }
    }

    @Override
    protected int getItemType(int position) {
        return 0;
    }

    @Override
    public int getLayoutId(int viewType) {
        return R.layout.item_activity_recoder_layout;
    }
}
